import React from 'react'
import { render } from 'react-dom'
import {Route, IndexRoute} from 'react-router';
import {combineReducers} from 'redux-immutable';

import 'antd/dist/antd.css';

import moment from 'moment';

// 推荐在入口文件全局设置 locale
import 'moment/locale/zh-cn';
moment.locale('zh-cn');

/**
 * 这里用来配置路由规则
 */
import App from './app/index';
// import Exam from './exam/components/index';
// import ExamDetail from './exam/components/ExamDetail';
// import ExamView from './exam/components/ExamView';

const routes = (
  // <Route path="/" breadcrumbName="主页" icon="home" component={App}>
  //   <IndexRoute component={Exam}/>
  //   <Route path="examlist" component={Exam} />
  //   <Route path="examdetail/:$loki"  component={ExamDetail} />
  //   <Route path="examview/:$loki"  component={ExamView} />
  // </Route>

  <Route path="/" component={App}>
    <IndexRoute getComponent={(nextState, cb) => {
      require.ensure([], require => {
        cb(null, require('./exam/components/index').default);
      });
    }}/>
    <Route path="examlist" getComponent={(nextState, cb) => {
      require.ensure([], require => {
        cb(null, require('./exam/components/index').default);
      });
    }}/>
    <Route path="examdetail/:$loki" getComponent={(nextState, cb) => {
      require.ensure([], require => {
        cb(null, require('./exam/components/ExamDetail').default);
      });
    }}/>
    <Route path="examview/:$loki" getComponent={(nextState, cb) => {
      require.ensure([], require => {
        cb(null, require('./exam/components/ExamView').default);
      });
    }}/>
    <Route path="score/:$loki" getComponent={(nextState, cb) => {
      require.ensure([], require => {
        cb(null, require('./score/index').default);
      });
    }}/>
  </Route>
);

/**
 * 这里用来load reducers
 */
import app from './app/reducer'; //app全局
import exam from './exam/reducer'; //面板首页
import score from './score/reducer'; //面板首页

const reducers = combineReducers({
  app,
  exam,
  score
});

/**
 * render document
 */
import Root from '../Root'
render(
  <Root routes={routes} reducers={reducers}/>,
  document.getElementById('layout')
);
